﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PSE.Framework.ErrorLogging;
using PSE.Framework.Configuration;
using PSE.Framework.Process;
using System.Windows;
using System.Diagnostics;

namespace Sinacor.UI.Versions.Application
{
    public class Program : BaseProgram
    {
        static Program()
        {
            Initialize(Sinacor.Infra.Common.Configuration.SystemComponents.System, Sinacor.Infra.Common.Configuration.SystemComponents.Versions);
        }

        [STAThread]
        static void Main(string[] args)
        {
            try
            {
                string systemName = "Sinacor";
                int majorVersion = 0;

                if (Debugger.IsAttached)
                {
                    majorVersion = 1;
                }
                else
                {
                    if (args == null)
                    {
                        System.Windows.MessageBox.Show("Empty args", "Versions", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    if (args.Length != 1)
                    {
                        System.Windows.MessageBox.Show("Invalid args", "Versions", MessageBoxButton.OK, MessageBoxImage.Error);
                        return;
                    }

                    majorVersion = Convert.ToInt32(args[0]);
                }

                VersionsApplication application = new VersionsApplication();
                application.SystemName = systemName;
                application.MajorVersion = majorVersion;
                application.Run();
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
    }
}
